package com.lovo.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lovo.bean.Tenderinfo2;
import com.lovo.service.ITenderinfo2Service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author lovo
 * @since 2022-09-17
 */
@RestController
@RequestMapping("hd/tenderinfo2")
public class Tenderinfo2Controller {

    @Autowired
    ITenderinfo2Service tenderinfo2Service;


    @GetMapping("findAllTenderInfo/{pageNO}")
    public IPage<Tenderinfo2> findAllTenderInfo(@PathVariable("pageNO") Integer pageNO) {
        return tenderinfo2Service.findAllTenderInfo(pageNO);
    }


    @PutMapping("updateTenderInfoStatus/{tenderInfoId}/{status}")
    public String updateTenderInfoStatus(@PathVariable("tenderInfoId") Integer tenderInfoId,
                                         @PathVariable("status") String status) {
        tenderinfo2Service.updateTenderInfoStatus(tenderInfoId, status);

        return "ok";
    }

    @PutMapping("updateInfoListStatus/{tenderId}/{status}")
    public String updateInfoListStatus(@PathVariable("tenderId") Integer tenderId,
                                       @PathVariable("status") String status) {


        List<Tenderinfo2> list = tenderinfo2Service.findInfoByTenderId(tenderId);
        list.forEach(n -> {
            tenderinfo2Service.updateTenderInfoStatus(n.getId(), status);
        });
        return "ok";


    }

}
